<template>
  <div id="dq" style="width: 1200px;height: 400px">

  </div>
</template>

<script>

  import { dq } from "@/api/building/dendrogram/index";
  export default {
    data(){
      return{
        data1:[],
        data2:[]
      }
    },
    methods:{
      dq(){
        console.log(this.data1)
        console.log(this.data2)
        // 基于准备好的dom，初始化echarts实例
        var myChart = this.$echarts.init(document.getElementById('dq'));
        // 绘制图表
        myChart.setOption({
          title: {
            text: '根据地址分类'
          },
          tooltip: {},
          xAxis: {
            data: this.data1
          },
          yAxis: {},
          series: [
            {
              name: '销量',
              type: 'bar',
              data: this.data2
            }
          ]
        });
      },
      dqs(){
        dq().then(res=>{
          console.log(res);
          this.data1 = res.map(item =>item.regionName)
          this.data2 = res.map(item =>item.regionId)
          this.dq();
        })
      }
    },
    mounted() {
      this.dqs();
    },
  }
</script>

<style scoped>

</style>
